package com.yuexun.dhdoctor.module.Contract.model.impl;


import com.yuexun.dhdoctor.base.BaseEntity;
import com.yuexun.dhdoctor.module.Contract.api.DeptApi;
import com.yuexun.dhdoctor.module.Contract.bean.ChildDepartmentsBean;
import com.yuexun.dhdoctor.module.Contract.bean.GroupDataBean;
import com.yuexun.dhdoctor.module.Contract.model.IDepartmentModel;
import com.yuexun.dhdoctor.util.ApiUtil;

import java.util.Map;

import rx.Observable;

/**
 * Created by work-jx on 2016/7/19.
 */
public class DepartmentModel implements IDepartmentModel {
    private DeptApi api;

    //记录Log
//    private final Logger log = ProUtil.getLogger(LoginModel.class);

    public DeptApi ApiInstance() {
        if (api != null) {
            return api;
        } else {
            return ApiUtil.getInstance().createRetrofitApi(DeptApi.class);
        }
    }

    @Override
    public Observable<BaseEntity<GroupDataBean>> getAllDepartment(Map<String, String> praise) {
        api = ApiInstance();
        return api.getAllDepartment(praise);
    }

    @Override
    public Observable<BaseEntity<GroupDataBean>> getDepartmentDatas(Map<String, String> praise) {
        api = ApiInstance();
        return api.getGroupDatas(praise);
    }

    @Override
    public Observable<BaseEntity<ChildDepartmentsBean>> getAllGroup(Map<String, String> praise) {
        api = ApiInstance();
        return api.getAllGroup(praise);
    }

}
